package com.example.sfm.controller;


import com.example.sfm.constant.MessageConstants;
import com.example.sfm.pojo.dto.CourseQueryDto;
import com.example.sfm.result.Result;
import com.example.sfm.service.ICoursesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sfm
 * @since 2025-03-07
 */
@RestController("userCoursesController")
@RequestMapping("/user/courses")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "用户课程相关接口", description = "用户课程相关接口")
public class CoursesController {

    private final ICoursesService courseService;

    /**
     * 获取所有课程
     *
     * @return 课程列表
     */
    @GetMapping("/list")
    @Operation(summary = "获取所有课程", description = "获取所有课程")
    public Result<?> listCourses(@ParameterObject CourseQueryDto dto) {
        log.info("分页课程列表:{}", dto);
        return Result.success(courseService.listCourses(dto), MessageConstants.SELECT_OK);
    }
}
